import scrapy
from sspai.items import GaoqingItem

class GaoqingfmSpider(scrapy.Spider):
    name = 'gaoqingfm'
    allowed_domains = ['gaoqing.fm']
    start_urls = ['http://gaoqing.fm/']

    def parse(self, response):
        for each in response.xpath('//*[@id="result1"]/li'):
            item = GaoqingItem()
            title = each.xpath("div/div[2]/p/a/text()").get()
            href = each.xpath("div/div[2]/p/a/@href").get()
            png = each.xpath("div/div[1]/a/div[1]/img/@src").get()

            if title and href is not None:
                item['title'] = title.strip()
                item['href'] = href.strip()
                item['png'] = png.strip()

                yield item
        
